<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="请输入身高(米)" v-model="h">
  <input type="text" placeholder="请输入体重(公斤)" v-model="w">
  <input type="button" value="测试" @click="f()">
  <h1>测试结果:{{info}}</h1>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<!--引入axios框架文件-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>

<script>
    let v = new Vue({
        el:"body>div",
        data:{
            info:"",h:"",w:""
        },
      methods:{
          f(){
            //发出异步请求
            axios.get("/bmi?h="+v.h+"&w="+v.w).then(function (response) {
              //请求成功后(服务器响应完之后)会执行此处的代码
              //response对象中的data属性是服务器响应的数据
              v.info = response.data;
            })
          }
      }
    })
</script>
</body>
</html>